package com.jiayang.module.station;

import com.jiayang.common.anno.NoNeedLogin;
import com.jiayang.common.anno.OperateLog;
import com.jiayang.common.domain.ResponseDTO;
import com.jiayang.constant.SwaggerTagConst;
import com.jiayang.module.station.domain.dto.StationFindDTO;
import com.jiayang.module.station.domain.entity.StationEntity;
import com.jiayang.module.system.login.domain.RequestTokenBO;
import com.jiayang.util.JYangRequestTokenUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * @ Author     ：OuyangChenglong
 * @ Date       ：Created in 13:19 2021/9/7
 * @ Description：场站相关API
 * @ Modified By：
 * @Version: 1.0$
 */
@RestController
@Api(tags = {SwaggerTagConst.Admin.MANAGER_STATION_CONFIG})
@OperateLog
public class StationController {

    @Autowired
    private StationService stationService;

    @PostMapping("/station/add")
    @ApiOperation(value = "新增场站", notes = "新增场站 @author OuyangChenglong")
    @NoNeedLogin
    public ResponseDTO<String> add(@Valid @RequestBody StationFindDTO sdto) {
        return stationService.add(sdto);
    }

    @GetMapping("/station/getStation")
    @ApiOperation(value = "获取符合该用户的场站列表", notes = "获取场站 @author OuyangChenglong")
    public ResponseDTO<List<StationFindDTO>> getStation() {
        RequestTokenBO requestToken = JYangRequestTokenUtil.getRequestUser();
        return stationService.getStation(requestToken);
    }


}
